#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<string>
#include<unordered_map>
#include<vector>
#include<algorithm>
using namespace std;

class Solution {
public:
    string printBin(double num) {
        string ret = "0.";
        int i = -1;
        while (num != 0)
        {
            double d = pow(2, i);
            if (num >= d) {
                ret += "1";
                num -= d;
            }
            else {
                ret += "0";
            }
            i--;
            if (ret.size() > 32) return "ERROR";
        }
        return ret;
    }
};

class Solution {
public:
    vector<vector<string>> groupAnagrams(vector<string>& strs) {
        unordered_map<string, vector<string>> hashMap;
        for (auto& str : strs) {
            string key = str;
            sort(key.begin(), key.end());
            hashMap[key].push_back(str);
        }

        vector<vector<string>> ret;
        for (auto& e : hashMap) {
            ret.push_back(e.second);
        }
        return ret;
    }
};